﻿using MSDIS.Configuration;
using MSDIS.Configuration.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace MSDIS.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            ConfigurationService service = new ConfigurationService();

            // IEnumerable<EndpointParameter> endpoints = (IEnumerable<EndpointParameter>)variable.Value;

            
            IEnumerable<RemoteService> services = new List<RemoteService>()
            {
                new RemoteService {
                    Name = "MSDIS",
                    Description = "Multi Surveillance Data Integration System",
                    Status = RemoteService.ServiceStatus.RUNNING
                },
                new RemoteService {
                    Name = "Reporting",
                    Description = "MSDIS Statistic Reporting Service",
                    Status = RemoteService.ServiceStatus.STOPPED
                }
            };

            IVariable variable0 = new Variable() { Name = "Services", DefaultValue = services, Value = services, Type = typeof(IEnumerable<RemoteService>) };

            service.CreateVariable(variable0);
            
            
            IEnumerable<EndpointParameter> endpoints = new List<EndpointParameter>()
            {
                new EndpointParameter { Id=0, Name="SSR Gateway", Address="224.10.7.252", Port=5201, Buffer=1024, Category=EndpointParameter.AsterixCategory.CAT062_V0_16, Status=EndpointParameter.EndpointStatus.ENABLED, Channel=EndpointParameter.DataChannel.INPUT },
                new EndpointParameter { Id=1, Name="ADS-B Gateway", Address="239.47.1.1", Port=28200, Buffer=1024, Category=EndpointParameter.AsterixCategory.CAT021_V2_1, Status=EndpointParameter.EndpointStatus.ENABLED , Channel=EndpointParameter.DataChannel.INPUT },
                new EndpointParameter { Id=2, Name="BKK Gateway", Address="224.1.2.125", Port=4100, Buffer=1024, Category=EndpointParameter.AsterixCategory.CAT062_V0_16, Status=EndpointParameter.EndpointStatus.DISABLED, Channel=EndpointParameter.DataChannel.INPUT },
                new EndpointParameter { Id=3, Name="MSDIS Gateway", Address="224.0.0.1", Port=5001, Buffer=1024, Category=EndpointParameter.AsterixCategory.CAT062_V0_16, Status=EndpointParameter.EndpointStatus.ENABLED, Channel=EndpointParameter.DataChannel.OUTPUT }
            };

            IVariable variable1 = new Variable() { Name = "Endpoints", DefaultValue = endpoints, Value = endpoints, Type = typeof(IEnumerable<EndpointParameter>) };

            service.CreateVariable(variable1);
            
            
            SecurityParameter parameter =
            new SecurityParameter
            {
                PrivateKeyPath = "private",
                PublicKeyPath = "public",
                PkiType = 128,
                CaUrl = "http://172.16.21.200:50000/CA",
                RaUrl = "http://172.16.21.200:50000/RA",
                VaUrl = "http://172.16.21.200:50000/VA"
            };

            IVariable variable2 = new Variable() { Name = "Security", DefaultValue = parameter, Value = parameter, Type = typeof(SecurityParameter) };

            service.CreateVariable(variable2);
            
            FusionParameter fusionParameter = new FusionParameter { Sic = 32, Sac = 45, RefLatitude = 13.5825, RefLongitude = 100.6585, PosResolution = 5, AltResolution = 1000, FusionRate = 1.0, PredictionTime = 5 };

            IVariable variable3 = new Variable() { Name = "Fusion", DefaultValue = fusionParameter, Value = fusionParameter, Type = typeof(FusionParameter) };

            service.CreateVariable(variable3);
            
            System.Console.Read();
        }
    }
}
